

clear

import excel using OrigData/NEXIS_Building_Exposure_SA1_v9.xls, firstrow

keep if STATE =="VIC"

save Data/NEXIS_data.dta, replace



clear

import excel OrigData/asgs2016_2016gridcorrespondences/CG_SA1_2016_POA_2016.xls, sheet("Table 3") cellrange(A6:C60318) firstrow

destring POA, replace

rename SA1_MAINCODE SA1CODE


save Data/SA1postcode2016.dta, replace




use Data/SA1postcode2016.dta, clear


joinby SA1CODE using Data/NEXIS_data.dta

rename POA_CODE postcode

foreach var in ROOFCO ROOFFI ROOFIM ROOFME ROOFSY ROOFTI {

	rename NUMBEROFBUILDINGSWITH`var' `var'
	
	}
	
rename R NUMBEROFBUILDINGSWITHWALLSMB



foreach var in WALLSA WALLSC WALLSF WALLSM WALLSMB WALLSP WALLSR WALLSS WALLST WALLSV {

	rename NUMBEROFBUILDINGSWITH`var' `var'
	
	}
	
	
	rename NUMBEROFRESIDENTIALDWELLINGS RESIDENTIALDWELLINGS
	rename NUMBEROFRESIDENTIALBUILDINGS RESIDENTIALBUILDINGS
	rename NUMBEROFBUILDINGSPRE1980 BUILDINGSPRE1980
	rename NUMBEROFBUILDINGSPOST1981 BUILDINGSPOST1981
	rename NUMBEROFBUILDINGSWITHUNKNOWN BUILDINGSWITHUNKNOWN
	

collapse (sum)  ROOF* WALLS* RESIDENTIAL* BUILDINGS* FLOOR* NUMBER*, by(postcode)

save Data/BuildingType.dta, replace
